package resource;

import java.io.File;

import main.Domandino;

public class Resource {
	private static final String questionsFileName = "questions.txt";
	private static final String progressFileName = "progress.txt";
	private static final String dateFileName = "date.txt";
	private static int RATIO = 5;
	
	public static void setRATIO(int r){
		if(r < 0 )
			throw new NumberFormatException("valore minore di 1 non ammesso");
		RATIO = r;
	}
	public static int getRATIO(){
		return RATIO;
	}



	public static String getProgressPath(){
		return getFolderPath()+progressFileName;
	}
	public static String getDateFilePath(){
		return getFolderPath()+dateFileName;
	}
	public static String getQuestionsFilePath(){
		return getFolderPath()+questionsFileName;
	}
	private static String getFolderPath(){
		
		String path = Domandino.class.getProtectionDomain().getCodeSource().getLocation().getPath();
		if(path.contains(".jar")){
			//levo name.jar
			int offSet = path.lastIndexOf(File.separator);
			path = path.substring(0, offSet+1);
		}else{
			//levo bin/
			path = path.substring(0, path.length()-4);
		}
		return path;
	}
	
	
}
